package Common;

public class EncryptClass
{
	/** 
	 ���췽��
	*/
	public EncryptClass()
	{
	}

	public static String SimpleEncrypt(String original)
	{
		return "";

	}
	/** 
	 ʹ��ȱʡ��Կ�ַ�������
	 
	 @param original ����
	 @return ����
	*/
	public static String Encrypt(String original)
	{
		return Encrypt(original, "SSLH");
	}
	/** 
	 ʹ��ȱʡ��Կ����
	 
	 @param original ����
	 @return ����
	*/
	public static String Decrypt(String original)
	{
		return Decrypt(original, "SSLH", System.Text.Encoding.Default);
	}
	/** 
	 ʹ�ø�����Կ����
	 
	 @param original ����
	 @param key ��Կ
	 @return ����
	*/
	public static String Decrypt(String original, String key)
	{
		return Decrypt(original, key, System.Text.Encoding.Default);
	}
	/** 
	 ʹ��ȱʡ��Կ����,����ָ�����뷽ʽ����
	 
	 @param original ����
	 @param encoding ���뷽ʽ
	 @return ����
	*/
	public static String Decrypt(String original, Encoding encoding)
	{
		return Decrypt(original, "SSLH", encoding);
	}
	/** 
	 ʹ�ø�����Կ����
	 
	 @param original ԭʼ����
	 @param key ��Կ
	 @param encoding �ַ����뷽��
	 @return ����
	*/
	public static String Encrypt(String original, String key)
	{
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] buff = System.Text.Encoding.Default.GetBytes(original);
		byte[] buff = System.Text.Encoding.Default.GetBytes(original);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] kb = System.Text.Encoding.Default.GetBytes(key);
		byte[] kb = System.Text.Encoding.Default.GetBytes(key);
		return Convert.ToBase64String(Encrypt(buff, kb));
	}

	/** 
	 ʹ�ø�����Կ����
	 
	 @param encrypted ����
	 @param key ��Կ
	 @param encoding �ַ����뷽��
	 @return ����
	*/
	public static String Decrypt(String encrypted, String key, Encoding encoding)
	{
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] buff = Convert.FromBase64String(encrypted);
		byte[] buff = Convert.FromBase64String(encrypted);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] kb = System.Text.Encoding.Default.GetBytes(key);
		byte[] kb = System.Text.Encoding.Default.GetBytes(key);
		return encoding.GetString(Decrypt(buff, kb));
	}
	/** 
	 ����MD5ժҪ
	 
	 @param original ����Դ
	 @return ժҪ
	*/
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public static byte[] MakeMD5(byte[] original)
	public static byte[] MakeMD5(byte[] original)
	{
		MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] keyhash = hashmd5.ComputeHash(original);
		byte[] keyhash = hashmd5.ComputeHash(original);
		hashmd5 = null;
		return keyhash;
	}

	/** 
	 ʹ�ø�����Կ����
	 
	 @param original ����
	 @param key ��Կ
	 @return ����
	*/
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public static byte[] Encrypt(byte[] original, byte[] key)
	public static byte[] Encrypt(byte[] original, byte[] key)
	{
		TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
		des.Key = MakeMD5(key);
		des.Mode = CipherMode.ECB;

		return des.CreateEncryptor().TransformFinalBlock(original, 0, original.length);
	}

	/** 
	 ʹ�ø�����Կ��������
	 
	 @param encrypted ����
	 @param key ��Կ
	 @return ����
	*/
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public static byte[] Decrypt(byte[] encrypted, byte[] key)
	public static byte[] Decrypt(byte[] encrypted, byte[] key)
	{
		TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
		des.Key = MakeMD5(key);
		des.Mode = CipherMode.ECB;

		return des.CreateDecryptor().TransformFinalBlock(encrypted, 0, encrypted.length);
	}

	/** 
	 ʹ�ø�����Կ����
	 
	 @param original ԭʼ����
	 @param key ��Կ
	 @return ����
	*/
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public static byte[] Encrypt(byte[] original)
	public static byte[] Encrypt(byte[] original)
	{
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] key = System.Text.Encoding.Default.GetBytes("SSLH");
		byte[] key = System.Text.Encoding.Default.GetBytes("SSLH");
		return Encrypt(original, key);
	}

	/** 
	 ʹ��ȱʡ��Կ��������
	 
	 @param encrypted ����
	 @param key ��Կ
	 @return ����
	*/
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public static byte[] Decrypt(byte[] encrypted)
	public static byte[] Decrypt(byte[] encrypted)
	{
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] key = System.Text.Encoding.Default.GetBytes("SSLH");
		byte[] key = System.Text.Encoding.Default.GetBytes("SSLH");
		return Decrypt(encrypted, key);
	}

}